Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RustyHog: improve description and file_path #11433

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

valentijnscholten
Copy link
Member

@valentijnscholten valentijnscholten commented Dec 17, 2024

Description
Improvements to Rusy Hog parser:

  • For Confluence and JIRA scans, set file_path to contain URL of scanned page;
  • Ensure found_secret_string is actually a String and not a list;
  • Add Reason to description;

Test results
Unit tests updated.

Documentation
No updates needed

Checklist

  • Make sure to rebase your PR against the very latest dev.
  • Features/Changes should be submitted against the dev.
  • Bugfixes should be submitted against the bugfix branch.
  • Give a meaningful name to your PR, as it may end up being used in the release notes.
  • Your code is flake8 compliant.
  • Your code is python 3.11 compliant.
  • If this is a new feature and not a bug fix, you've included the proper documentation in the docs at https://github.com/DefectDojo/django-DefectDojo/tree/dev/docs as part of this PR.
  • Model changes must include the necessary migrations in the dojo/db_migrations folder.
  • Add applicable tests to the unit tests.
  • Add the proper label to categorize your PR.

Copy link

dryrunsecurity bot commented Dec 17, 2024

DryRun Security Summary

The code changes enhance the RustyhogParser class by improving the test suite and vulnerability reporting capabilities, focusing on detecting and providing detailed information about sensitive data disclosure in various repositories and collaboration tools.

Expand for full summary

Summary:

The provided code changes focus on enhancing the RustyhogParser class, which is responsible for parsing the output of the "Rusty Hog" security tool. The changes include improvements to the test suite, which covers various scenarios related to the detection of sensitive information disclosure, such as SSH private keys, passwords, and other confidential data found in code repositories, configuration files, and collaboration tools. Additionally, the code changes in the parser.py file aim to provide more detailed and informative vulnerability descriptions, including specific details about the identified issues, such as commit information, file paths, line numbers, diffs, and relevant IDs from JIRA and Confluence. These enhancements improve the overall quality and usefulness of the vulnerability reporting, making it more effective in identifying and addressing potential security issues.

Files Changed:

  1. unittests/tools/test_rusty_hog_parser.py:

    • This file contains the test suite for the RustyhogParser class, which covers various scenarios, including files with no vulnerabilities, files with a single vulnerability, and files with multiple vulnerabilities.
    • The test cases highlight the parser's ability to detect sensitive information, such as SSH private keys, passwords, and other confidential data found in different locations (e.g., Confluence pages, file paths, JIRA tickets).
    • The test cases also demonstrate the parser's ability to extract detailed information about the commits associated with the identified vulnerabilities, including the commit message, commit hash, parent commit hash, and the file changes.
    • The test cases show that the parser provides mitigation recommendations for the identified issues, guiding developers and security teams on how to address the vulnerabilities.
  2. dojo/tools/rusty_hog/parser.py:

    • The changes in this file focus on improving the handling and presentation of the vulnerability information obtained from various "Hog" scanners (Choctaw Hog, Duroc Hog, Gottingen Hog, and Essex Hog).
    • The code now ensures that the "reason" and "stringsFound" information are properly handled and included in the vulnerability description, even if they are None or empty.
    • The code extracts and includes additional relevant details in the vulnerability description, such as commit information, file paths, line numbers, diffs, JIRA issue IDs, and Confluence page IDs, depending on the scanner type.
    • The code provides specific mitigation recommendations based on the scanner type, advising the user to ensure that no secret material or confidential information is kept in clear within the respective locations (Git repositories, directories/files/archives, JIRA tickets, or Confluence pages).
    • If the file path is not available from the vulnerability information, the code attempts to use the provided URL as a fallback.

Code Analysis

We ran 9 analyzers against 2 files and 0 analyzers had findings. 9 analyzers had no findings.

View PR in the DryRun Dashboard.

@valentijnscholten
Copy link
Member Author

valentijnscholten commented Dec 17, 2024

Just realized this may affect hash_code calculation, so these need to be updated on upgrading.
Should this happen in a migration, or just instructions be added to the upgrade notes as was done on earlier releases?
A similar case in #11419 seems to be OK without either.

@valentijnscholten valentijnscholten changed the base branch from master to dev December 17, 2024 18:35
@valentijnscholten valentijnscholten force-pushed the rustyhog-improvements-2024 branch from 4101de6 to 094c350 Compare December 17, 2024 18:38
@valentijnscholten valentijnscholten marked this pull request as ready for review December 17, 2024 20:06
@valentijnscholten
Copy link
Member Author

wdyt about the PR @Maffooch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant